<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>分配网点</title>
<script type="text/javascript">
<%--存数数组--%>
var array = new Array();
<%--通函--%>
var _$ = function(id){return document.getElementById(id);};
var _clear = function(id){_$(id).value="";};
<%--初始化信息--%>
var _myinit = function(){
	var content = "";
	for(var i=0;i<array.length;i++){
		var obj = eval('(' + array[i] + ')');
		content += "<tr><td class='center' style='width: 85px;'>"+i+"</td>";
		content += "<td class='center' style='width: 85px;'>"+obj.daily_time+"</td>";
		content += "<td class='center' style='width: 85px;'>"+obj.daily_type+"</td>";
		content += "<td class='center' style='width: 173px;'>"+obj.daily_detail+"</td>";
		content += "<td class='center' style='width: 173px;'>"+obj.daily_result+"</td>";
		content += "<td class='center' style='width: 85px;'>"+obj.daily_content+"</td>";
		content += "<td class='center' style='width: 85px;'><em onclick='_delete(\""+i+"\")'>删除</em></td>";
	}
	_$("tbody_table").innerHTML=content;
};
<%--页面初始化时重量输入框获取按钮并初始化信息--%>
$(function(){
	_$("daily_time").focus();
});
<%--监控重量输入框确定事件--%>
/* var _order_weight = function(e){
	var event = e || window.event;
	if(event.keyCode==13){
		_$("order_weight").readOnly = true;
		_$("order_qrCode").focus();
	}
}; */
<%--重新录入--%>
var _reset = function(){
	_$("daily_time").focus();
	_$("daily_time").value = "";
	_$("daily_type").value = "";
	_$("daily_detail").value="";
	_$("daily_result").value="";
	_$("daily_content").value="";
};
<%--删除选项--%>
var _delete = function(id){
	var ay = new Array();
	var length = 0;
	for(var i=0;i<array.length;i++){
		if(i!=id){
			ay[length] = array[i];
			length ++;
		}
	}
	array = ay;
	_myinit();
	_$("daily_time").readOnly = false;
	_$("daily_time").focus();
};
<%--编辑--%>
var _edit = function(id){
	var obj = eval('(' + array[id] + ')');
	_$("order_weight").readOnly = false;
	_$("order_weight").value = obj.order_weight;
	_$("order_weight").focus();
	_$("order_tiji").value=obj.order_tiji;
	_$("order_qrCode").value=obj.qrCode;
	_delete(id);
};
<%--监控二维码输入框确定事件--%>
var _order_qrcode = function(e){
	var event = e || window.event;
	if(event.keyCode==13){
		var daily_time = $.trim(_$("daily_time").value);
		var daily_type = $.trim(_$("daily_type").value);
		var daily_detail = $.trim(_$("daily_detail").value);
		var daily_result = $.trim(_$("daily_result").value);
		var daily_content = $.trim(_$("daily_content").value);
		if(daily_time==null || daily_time==""){
			alert("时间不能为空");
			return ;
		}
		if(daily_type==null || daily_type==""){
			alert("事项不能为空");
			return ;
		}
		if(daily_detail==null || daily_detail==""){
			alert("内容不能为空");
			return ;
		}
		if(daily_result==null || daily_result==""){
			alert("结果不能为空");
			return ;
		}
		if(daily_content==null || daily_content==""){
			alert("备注不能为空");
			return ;
		}
		<%--
		if(_weight_init<11){price = 4 + (_weight_init - 1);
		}else if(_weight_init<31){price = 15 + (_weight_init - 10) * 5;
		}else{price = 100 + (_weight_init - 30) * 10;}--%>
		var item = "{\"daily_time\":\""+daily_time+"\",\"daily_type\":\""+daily_type+"\",\"daily_detail\":\""+daily_detail+"\",\"daily_result\":\""+daily_result+"\",\"daily_content\":\""+daily_content+"\"}";
		array[array.length] = item;
		_myinit();
/* 		_$("order_weight").readOnly = false; */

		_$("daily_time").focus();
		_$("daily_time").value = "";
		_$("daily_type").value = "";
		_$("daily_detail").value="";
		_$("daily_result").value="";
		_$("daily_content").value="";
	}
};

var _commit = function(){
		var daily_time = $.trim(_$("daily_time").value);
		var daily_type = $.trim(_$("daily_type").value);
		var daily_detail = $.trim(_$("daily_detail").value);
		var daily_result = $.trim(_$("daily_result").value);
		var daily_content = $.trim(_$("daily_content").value);
		if(daily_time==null || daily_time==""){
			alert("时间不能为空");
			return ;
		}
		if(daily_type==null || daily_type==""){
			alert("事项不能为空");
			return ;
		}
		if(daily_detail==null || daily_detail==""){
			alert("内容不能为空");
			return ;
		}
		if(daily_result==null || daily_result==""){
			alert("结果不能为空");
			return ;
		}
		if(daily_content==null || daily_content==""){
			alert("备注不能为空");
			return ;
		}
		<%--
		if(_weight_init<11){price = 4 + (_weight_init - 1);
		}else if(_weight_init<31){price = 15 + (_weight_init - 10) * 5;
		}else{price = 100 + (_weight_init - 30) * 10;}--%>
		var item = "{\"daily_time\":\""+daily_time+"\",\"daily_type\":\""+daily_type+"\",\"daily_detail\":\""+daily_detail+"\",\"daily_result\":\""+daily_result+"\",\"daily_content\":\""+daily_content+"\"}";
		array[array.length] = item;
		_myinit();
/* 		_$("order_weight").readOnly = false; */

		_$("daily_time").focus();
		_$("daily_time").value = "";
		_$("daily_type").value = "";
		_$("daily_detail").value="";
		_$("daily_result").value="";
		_$("daily_content").value="";
	};
var _reg = function(){
	var json="["+array+"]";
	$.ajax({
        type: 'post',
        url:'<%=basePath%>addBDDaily',
		data : {
			json : json
		},
		success : function(data) {
			var returnjson=eval('('+data+')');
			if(returnjson.success)
			{
				alertMsg.correct("处理成功！");
				array = new Array();
				_myinit();
				_reset();
			}else{
				alertMsg.correct("处理失败！");
			}
		}
		});
};
</script>
</head>
<body>
	<div class="pageContent">
		<div class="pageFormContent" layoutH="56">
			<table class="table">
				<thead>
					<tr>
						<th width="100" align="center">id</th>
						<th width="100" align="center">时间</th>
						<th width="100" align="center">事项</th>
						<th width="200" align="center">过程说明</th>
						<th width="200" align="center">结果展示</th>
						<th width="100" align="center">备注</th>
						<th width="100" align="center">删除</th>
					</tr>
				</thead>
				<tbody id="tbody_table"></tbody>
			</table>
			<br> <br> <br> <br>
			<table>
				<tr>
					<td>时间：</td>
					<td><input type="text" id="daily_time" name="time" style="width: 100px;" onkeyup="" /></td>
				</tr>
				<tr>
				<td>事项：</td>
					<td>
					<select id="daily_type">
						<option>扫楼+地推</option>
						<option>企业洽谈</option>
						<option>快递员事务</option>
						<option>其他</option>
					</select>
					
					<!-- <input type="text" id="daily_type" name="type" style="width: 100px;" onkeyup="" /></td> -->
				</tr>
				<tr><td>过程说明：</td>
				<td><input type="text" id="daily_detail" name="detail" style="width: 600px;" onkeyup=""/></span></td>
				</tr>
				<tr>
					<td>结果展示：</td>
					<td><input type="text" id="daily_result" name="result" style="width: 600px;" onkeyup=""/></span></td>
				</tr>
				<tr>
				<td>备注：</td>
					<td><input type="text" id="daily_content" name="content" style="width: 100px;" onkeyup="_order_qrcode(event)" /></td>
				</tr>
				<tr><td><input type="button" value="确定" onclick="_commit()"/></td>
					<td><input type="button" value="重新录入" onclick="_reset()"/></td>
				</tr>
				
			</table>
		</div>
		<input type="button" value="提交日志" onclick="_reg()"/>
	</div>
	
</body>
</html>
